package rcppart;

import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.console.MessageConsoleStream;

public class ConsoleUtil {
	
	public static void openConsole(){
		ConsoleViewPart.showConsole();
	}
	public static void printMessage(final String message) {
		Display.getDefault().asyncExec(new Runnable() {
			@Override
			public void run() {
				MessageConsoleStream consoleStream = ConsoleViewPart.getConsole().newMessageStream();
				consoleStream.setColor(new Color(null, 0, 100, 0));
				consoleStream.println(message);
			}
		});
	}
	
	public static void printError(final String message) {
		Display.getDefault().asyncExec(new Runnable() {
			@Override
			public void run() {
				MessageConsoleStream consoleStream = ConsoleViewPart.getConsole().newMessageStream();
				consoleStream.setColor(new Color(null, 255, 0, 0));
				consoleStream.println(message);
			}
		});
	}
}
